import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/login'
  },
  {
    path: '/home/:id',
    redirect: '/welcome',
    children: [
      {
        path: '/welcome',
        name: 'welcome',
        component: () => import('../components/Welcome.vue')
      },
      {
        path: '/goods',
        name: 'goods',
        component: () => import('../components/Goods.vue')
      },
      {
        path: '/orders',
        name: 'orders',
        component: () => import('../components/Orders.vue')
      },
      {
        path: '/comment',
        name: 'comment',
        component: () => import('../components/Comment.vue')
      },
      {
        path: '/inventory',
        name: 'inventory',
        component: () => import('../components/Inventory.vue')
      },
      {
        path: '/attribute',
        name: 'attribute',
        component: () => import('../components/Attribute.vue')
      }
    ],
    component: () => import('../views/HomeView.vue')
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/LoginView.vue')
  },
  {
    path: '/about',
    name: 'about',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  }

]

const router = new VueRouter({
  mode: 'history',
  routes
})

export default router
